<!DOCTYPE html>
<html lang="en">
<head>
  <title>MC System, the musical cryptosystem</title>
  <link href='http://fonts.googleapis.com/css?family=Permanent+Marker' rel='stylesheet' type='text/css'>
  <link href='http://fonts.googleapis.com/css?family=Droid+Sans' rel='stylesheet' type='text/css'>
  <style type="text/css">
    * { margin: 2px; padding: 2px; }
    body { font: 18px 'Droid Serif', Georgia, Arial, serif; background-color: #000000; background-image: url("bg.png"); background-position: center center; background-attachment: fixed; background-repeat: no-repeat }
    h1 { font-family: 'Permanent Marker', Georgia, serif; font-size: 115px; color: #000000; text-align: center; font-weight: normal; }
    h2 { font-family: 'Permanent Marker', Georgia, serif; font-size: 32px; color: #000000; text-align: center; font-weight: normal; }
    h3 { font-family: 'Permanent Marker', Georgia, serif; font-size: 20px; color: #000000; text-align: center; font-weight: normal; }
    p { text-align: justify; }
    p:first-letter { font: 41px 'Permanent Marker', Georgia, serif; color: #000000; padding: 5px; float: left; }
    a:link { color: #003ac2; text-decoration: none; }
    a:visited { color: #003ac2; text-decoration: none; }
    a:active { color: #003ac2; text-decoration: none; }
    a:hover { color: #003ac2; text-decoration: none; }
    a span.text { display: inline; }
    a:hover span.text { display: none; }
    a span.scramble { display: none; }
    a:hover span.scramble { display: inline; }
    div#shadow { width: 620px; margin: auto; padding-bottom: 10px; background-color: #ffffff; box-shadow:0px 20px 20px #ffffff; -webkit-box-shadow:0px 20px 20px #ffffff; -moz-box-shadow: 0px 20px 20px #ffffff; }
    div#links { text-align: center; margin: 15px; border-width: 3px; border-style: outset; border-color: #00081a; }
    table { margin-left: auto; margin-right: auto; text-align: center }
  </style>
</head>
<body>
  <div id="shadow">
    <h1>MC System</h1>
    <h3>"If cryptography is outlawed, bayl bhgynjf jvyy unir cevinpl"</h3>
    <div style="width: 520px; margin: auto;">
      <div id="links">
      <table width="100%" align="center">
          <tr>
          
<?php
  //Author: Jonathan Anders geminii@citcom.net
  function Scramble($dString) {
    $strOne = "";
    $strTwo = "";
    $i = 0;
    $x = 0;
    $dString = explode(" ",$dString);
    for ($x=0; $x < count($dString); $x++) {
      $dStr = $dString[$x];
      srand ((double) microtime() * 10000000);
      for ($i=0; $i < strlen($dStr); $i++) {
        $strOne = rand(0, strlen($dStr) - 1);
        $strTwo = $dStr[$i];
        $dStr[$i] = $dStr[$strOne];
        $dStr[$strOne] = $strTwo;
      }
      $dReturn .= " ".$dStr;
    }
    return $dReturn;
  }
?>
<?php
  echo '<td width="20%"><a href="#encrypt"><span class="text">Encrypt</span><span class="scramble">' . Scramble("Encrypt") . '</span></a></td>';
  echo '<td width="20%"><a href="#decrypt"><span class="text">Decrypt</span><span class="scramble">' . Scramble("Decrypt") . '</span></a></td>';
  echo '<td width="20%"><a href="#about"><span class="text">About</span><span class="scramble">' . Scramble("About") . '</span></a></td>';
  echo '<td width="20%"><a href="#examples"><span class="text">Examples</span><span class="scramble">' . Scramble("Examples") . '</span></a></td>';
  echo '<td width="20%"><a href="http://code.google.com/p/mcsystem/source/browse/trunk/mcsystem/" target="_blank"><span class="text">Source</span><span class="scramble">' . Scramble("Source") . '</span></a></td>';
?>
          </tr>
      </table>
    </div>
<p>Aesthetic objects are appreciated when the evaluators of those objects find meaning within them. Music and text are two familiar classes of such objects. MC System is a musical cryptosystem that encrypts English text into music and thereby creates new aesthetic objects. The music it creates can be heard for appreciation or act as a vehicle for the transmission of secret messages.<br /><br />

Using MC System is easy. To encrypt a message, type it into the text area below and upload any MIDI music file. The notes of the uploaded music serve as the private encryption key, so the piece must have at least as many notes as the alphabet. To decrypt a piece of music, upload an encrypted MIDI music file and the MIDI music key used to make it.</p><br />

<h2><a name="encrypt">Encrypt</a></h2>
<div align="center" style="margin: auto">
<form action="encrypt.php" method="post" enctype="multipart/form-data">
  <textarea name="message" id="message" rows="4" cols="50"></textarea><br />
  <label for="file">Key (MIDI):</label>
  <input type="file" name="file" id="file" /><br />
  <input type="submit" name="encrypt" value="Encrypt" />
</form>
</div>
<br />
<h2><a name="decrypt">Decrypt</a></h2>
<div align="center" style="margin:auto">
  <form action="decrypt.php" method="post" enctype="multipart/form-data">
  <table>
    <tr>
      <td align="right"><label for="file">Encrypted file (MIDI):</label></td>
      <td><input type="file" name="file" id="file" /><br /></td>
    </tr>
      <td align="right"><label for="key">Key (MIDI):</label></td>
      <td><input type="file" name="key" id="key" /><br /></td>
    </tr>
  </table>
  <input type="submit" name="decrypt" value="Decrypt" />
</form>
</div><br />

<h2><a name="about">About</a></h2>
<p>MC System is essentially a substitution cipher. Encryption is achieved by mapping the most frequent letters of the <a href="http://gutenberg.org/" target="_blank"><?php echo '<span class="text">Project Gutenberg</span><span class="scramble">' . Scramble("Project Gutenberg") . '</span>' ?></a> digital book archive to the most frequent notes of the private key and then substituting the letters of the input text. Decryption is achieved by the exact reversal of this process, where the most frequent notes of the key are substituted for the most frequent letters.<br /><br />

MC System is <a href="&#109;&#097;&#105;&#108;&#116;&#111;:earlbellinger&#064;gmail.com"><?php echo '<span class="text">Earl Bellinger</span><span class="scramble">' . Scramble("Earl Bellinger") . '</span>' ?></a>'s final project for the SUNY Oswego Honors Capstone course HON301: In Search of Meaning. This program is an investigation into the <a href=".."><?php echo '<span class="text">previously expressed</span><span class="scramble">' . Scramble("previously expressed") . '</span>' ?></a></a> curiosity in representing a notation with another. Words and music are mediums of human expression. Text and musical notation alike capture instructions for the production of aural events whose intentions are those of being perceived and processed by other humans. Speech and MIDI files are types of performances for those instructions. But they are not the only possible performances, and provided there exists a key to translate the new into the old, meaning is preserved. The key for text itself is presumably an unspoken agreement consisting of associating sounds with real things. Interesting possibilities arise when transforming text into music. For instance, musicians with agreement on a chosen key could use their instruments to communicate ideas in English.<br /><br />

The project synthesizes themes with two other courses taken during the same semester, MAT/CSC332: Cryptology and CSC466: Artificial Intelligence and Heuristic Programming, the latter of which fostered the creation of <a href="../../littleludwig"><?php echo '<span class="text">The Little Ludwig</span><span class="scramble">' . Scramble("The Little Ludwig") . '</span>' ?></a>, an evolutionary learning machine for musical composition. This program is dedicated to two Princeton alumni logicians: Alan Turing, who, amongst many other things, designed in 1939 an electromechanical device to decipher encrypted German messages; and David Vampola, my wonderful professor for this course. I also thank John Familo for providing the awesome sauce. Really, the sauce is quite good.<br /><br />

The <a href="http://code.google.com/p/mcsystem/source/browse/trunk/mcsystem/" target="_blank"><?php echo '<span class="text">source code</span><span class="scramble">' . Scramble("source code") . '</span>' ?></a> has been released for free under the GNU General Public License version 3. The front end uses PHP and the back end uses Java. The processing of MIDI files utilizes the <a href="http://jfugue.org" target="_blank"><?php echo '<span class="text">JFugue</span><span class="scramble">' . Scramble("JFugue") . '</span>' ?></a> music programming library.</p><br />

<h2><a name="examples">Examples</a></h2>
</div>
<table align="center" border=1 rules="rows" frame="hsides">
  <tr>
    <td>Plaintext</td>
    <td>Key</td>
  </tr>
  <tr>
    <td>if the world had no substance then whether a proposition had sense would depend on whether another proposition was true it would then be impossible to form a picture of the world true or false</td>
    <td><a href="ex/keys/lz.mid"><?php echo '<span class="text">"Babe I\'m Gonna Leave You" by Led Zeppelin</span><span class="scramble">' . Scramble('"Babe I\'m Gonna Leave You" by Led Zeppelin') . '</span>' ?></a></td>
    <td><a href="ex/enc/wittgenstein.mid"><?php echo '<span class="text">Encrypted music</span><span class="scramble">' . Scramble("Encrypted music") . '</span>' ?></a></td>
  </tr>
  <tr>
    <td>there is no logical impossibility in the hypothesis that the world sprang into being five minutes ago exactly as it then was with a population that remembered a wholly unreal past</td>
    <td><a href="ex/keys/beethoven.mid"><?php echo '<span class="text">Ludwig van Beethoven\'s Sonata No. 14 C# minor, 3rd Movement</span><span class="scramble">' . Scramble('Ludwig van Beethoven\'s Sonata No. 14 C# minor, 3rd Movement') . '</span>' ?></a></td>
    <td><a href="ex/enc/russell.mid"><?php echo '<span class="text">Encrypted music</span><span class="scramble">' . Scramble("Encrypted music") . '</span>' ?></a></td>
  </tr>
  <tr>
    <td>to every omega consistent recursive class k of formulae there correspond recursive class signs r such that neither v gen r nor neg v gen r belongs to flg  where v is the free variable of r</td>
    <td><a href="ex/keys/chopin.mid"><?php echo '<span class="text">Frederic Chopin\'s Winter Wind</span><span class="scramble">' . Scramble('Frederic Chopin\'s Winter Wind') . '</span>' ?></a></td>
    <td><a href="ex/enc/godel.mid"><?php echo '<span class="text">Encrypted music</span><span class="scramble">' . Scramble("Encrypted music") . '</span>' ?></a></td>
  </tr>
  <tr>
    <td>civilization advances by extending the number of important operations which we can perform without thinking of them </td>
    <td><a href="ex/keys/grieg.mid"><?php echo '<span class="text">Edvard Grieg\'s March of the Dwarfs</span><span class="scramble">' . Scramble('Edvard Grieg\'s March of the Dwarfs') . '</span>' ?></a></td>
    <td><a href="ex/enc/whitehead.mid"><?php echo '<span class="text">Encrypted music</span><span class="scramble">' . Scramble("Encrypted music") . '</span>' ?></a></td>
  </tr>
  <tr>
    <td>the idea behind digital computers may be explained by saying that these machines are intended to carry out any operations which could be done by a human computer</td>
    <td><a href="ex/keys/grieg.mid"><?php echo '<span class="text">Claude Debussy\'s Passepied</span><span class="scramble">' . Scramble('Claude Debussy\'s Passepied') . '</span>' ?></a></td>
    <td><a href="ex/enc/turing.mid"><?php echo '<span class="text">Encrypted music</span><span class="scramble">' . Scramble("Encrypted music") . '</span>' ?></a></td>
  </tr>
</table>
  </div>
</body>
</html>
